package packet;

import shared.Consts.Priorities;
import server.Game;
import server.Lobby;

/**
 *
 * @author Joel Garboden
 */
public class PlayerJoinReq extends Request
{
  private String name;

  /**
   *
   * @param playerID
   * @param name
   */
  public PlayerJoinReq(int playerID, String name)
  {
    this.playerID = playerID;
    this.name = name;
    this.priority = Priorities.URGENT;
  }

  @Override
  public boolean lobbyRequest(Lobby lobby)
  {
    lobby.playerJoinCmd(lobby.numChatters() - 1, name);
    return true;
  }

  @Override
  public boolean processRequest(Game game)
  {
    game.updateName(playerID, name);
    return true;
  }

  @Override
  public String toString()
  {
    return "playerJoinRequest: ";
  }
}
